<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('xdebug.max_nesting_level', 200);

define('DS'         , DIRECTORY_SEPARATOR);
define('ENV'        , 'dev');
define('ROOT_DIR'   , __DIR__ . DS . '..' . DS);

require_once ROOT_DIR . 'Shared' . DS . 'Application.php';
        
if(isset($_SERVER['HTTP_X_REAL_IP'])){
    $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_REAL_IP'];
}

$App = Shared\Application::getInstance();

if ( isset($_SERVER['HTTP_CLIENT_IP']) || 
    (
        strpos($_SERVER['REMOTE_ADDR'], '192.168.') !== 0 &&
        !in_array(@$_SERVER['REMOTE_ADDR'], array(
                '46.10.101.70', 
                '10.8.0.11',
                '78.83.223.209',
            )
        )
    )
) {
    $App->createException('restricted', 404);
    exit;
}

$App->setEnvironment(ENV);
$App->cacheClear();
$App->run();

echo $App->getFrontController()->getHtml();
exit();